package com.timber.util;

import java.awt.event.*;
import java.util.*;
import javax.swing.*;


public class UpperCaseComboBox extends SLComboBox
{
  public UpperCaseComboBox()
  {
    super();
    init();
  }

  public UpperCaseComboBox( ComboBoxModel aModel )
  {
    super( aModel );
    init();
  }

  public UpperCaseComboBox( Object[] items )
  {
    super( items );
    init();
  }

  public UpperCaseComboBox( Vector items )
  {
    super( items );
    init();
  }

  protected void init()
  {
    JTextField tf = ( JTextField )getEditor().getEditorComponent();
    tf.setDocument( new UpperCaseDocument() );
    tf.addFocusListener( new SelectTextFocusHandler() );
    addActionListener( new ActionListener()
      {
	public void actionPerformed( ActionEvent e )
	{
	  Object selectedItem = getSelectedItem();
	  if (( selectedItem == null ||
	      selectedItem.toString() == null ||
	      selectedItem.toString().trim().length() == 0 ) &&
              (getItemCount() > 0))
	    setSelectedIndex( 0 );
	}
      } );
  }






}
